//
// Description: 9. 分组背包问题
// Created by Loading on 2022/6/1.
//

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 110;

int v[N][N], w[N][N], s[N];
int dp[N];

int main() {
    int n, V;
    cin >> n >> V;
    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
        for (int j = 1; j <= s[i]; ++j) {
            cin >> v[i][j] >> w[i][j];
        }
    }

    /* 背包问题先枚举物品，再枚举体积，再枚举决策 */
    for (int i = 1; i <= n; ++i) {
        for (int j = V; j >= 0; --j) {
            for (int k = 1; k <= s[i]; ++k) {
                if (j >= v[i][k]) {
                    dp[j] = max(dp[j], dp[j - v[i][k]] + w[i][k]);
                }
            }
        }
    }

    cout << dp[V] << endl;

    return 0;
}